﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>方向条件-按照SQL计算</title>
    <link href="../../Scripts/easyUI145/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../../Scripts/bootstrap/js/jquery.min.js"></script>
    <script type="text/javascript" src="../../Scripts/bootstrap/js/bootstrap.min.js"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../Scripts/config.js" type="text/javascript"></script>
    <script src="../../Comm/Gener.js" type="text/javascript"></script>
    <script src="../Admin.js" type="text/javascript"></script>

    <link href="../../Style/skin/css/Default.css" rel="stylesheet" />
    <link href="../../Style/skin/adminfont/iconfont.css" rel="stylesheet" />
    <link href="../../Scripts/bootstrap/css/bootstrap.min.css" rel="stylesheet" />

    <link href="../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <base target="_self" />

    <script type="text/javascript">

        function Esc() {
            if (event.keyCode == 27)
                window.close();
            return true;
        }
        var condOrAnd = GetQueryString("CondOrAnd");
        //初始化页面函数.....
        $(function () {
            //绑定查询.
            var mypk = GetQueryString("MyPK");
            var cond = new Entity("BP.WF.Template.Cond");
            if (mypk != null && mypk != undefined && mypk != "") {
                cond.MyPK = mypk;
                cond.SetPKVal(mypk);
                cond.RetrieveFromDBSources();
            }

            GenerBindEntities("DDL_Template", "BP.WF.Template.SQLTemplates", cond.OperatorValue, "SQLType=0");
            $("#TB_Note").val(cond.Note);
        });

        //执行保存..
        function Save() {
            var sqlVal = $("#DDL_Template").val(); //  document.getElementById("DDL_Template").value;
            var note = document.getElementById("TB_Note").value;

            if (note == "") {
                alert('请输入备注说明.');
                return;
            }
            var sqlValT = $("#DDL_Template").find("option:selected").text();
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_Cond");
            handler.AddUrlData();
            handler.AddPara("TB_Docs", sqlVal);
            handler.AddPara("SqlValT", sqlValT);
            handler.AddPara("TB_Note", note);
            var data = handler.DoMethodReturnString("CondBySQLTemplate_Save");

            if (data.indexOf('err@') == 0) {
                $("#Msg").html("<font color=red>" + data + "</font>");
                return;
            }
            if (data.indexOf('url@') == 0) {
                var url = data.replace('url@', '');
                SetHref(url);
                return;
            }
            Back();
        }

        
        //装载模版.
        function LoadTemplate() {
            //打开方向条件.
            var url = "../SettingTemplate.htm?TemplateType=CondBySQLTemplateTemplate&CondType=2&m=" + Math.random();
            WinOpen(url, 'ss');
        }
        //返回.
        function Back() {
           var url = GetHrefUrl();

            url = url.replace('CondBySQLTemplate.htm', 'List.htm');
            if (url.indexOf("MyPK=") != -1) {
                url = url.replace("&MyPK=" + GetQueryString("MyPK"), "");
            }
            SetHref(url);
          
        }
    </script>
</head>
<body onkeypress="Esc();">
    <div class="container-full">
        <div class="attrnode-bar-header">
            <span class="pull-right">
                <button id="Btn_Save" name="Btn_Save" onclick="Save();">保存</button>
                <button id="Btn_Back" name="Btn_Back" onclick="Back();">返回</button>

            </span>
            <strong>方向条件-按照SQl</strong>
        </div>
        <form id="cc">
            <!--div style="right:30px; position:absolute; z-index:100; ">
        <input id="Btn_Save" type="button" value="保存" onclick="Save()" />
        <<input type="button" value="删除" onclick="Delete()" />>
        <input type="button" onclick="Back()" value="返回" id="Btn_Back" />
    </div-->
            <table class="table">

                <tr>
                    <td style="width: 20%;">
                        选择一个SQL模版:
                    </td>
                    <td>
                        <select id="DDL_Template" name="DDL_Template">
                        </select>
                        <!--<textarea rows="4"  style="width:95%;" id="TB_Docs" name="TB_Docs" > </textarea>-->
                    </td>
                </tr>
                <tr>
                    <td>
                        备注(不为空):
                    </td>
                    <td>
                        <input type="text" value="" id="TB_Note" name="TB_Note" style="width: 95%;" />
                    </td>
                </tr>
            </table>

            <div style="text-align: left">
                <h4>
                    &nbsp; &nbsp; &nbsp; &nbsp;帮助
                </h4>
                <ul>
                   
                        <li>该功能是为了方便业务人员设置个性化的SQL的条件.</li>
                        <li>开发人员把sql条件设置好，起一个容易识别的中文名字，让流程开发人员方便设置于选择使用，点击这里<a href="javascript:WinOpen('/WF/Comm/Search.htm?EnsName=BP.WF.Template.SQLTemplates&SQLType=0')">执行SQL模版设置</a>.</li>
                        <li>在文本框里设置一个查询SQL，它返回一行一列。比如: SELECT COUNT(*) AS Num FROM MyTable WHERE NAME='@MyFieldName'。</li>
                        <li>该SQL参数支持系统的表达式，什么是ccflow的表达式请查看说明书。</li>
                        <li>当前登录信息变量: @WebUser.No, @WebUser.Name, @WebUser.FK_Dept.</li>
                        <li>系统就会获取该返回的值把它转化为decimal类型</li>
                        <li>如果该值大于零，该条件就是成立的否则不成立。</li>
                  
                </ul>
            </div>
        </form>
        <center>
            <div id="Msg" />
        </center>
    </div>
</body>
</html>
